package com.example.demo.service;

import com.example.demo.dao.TableMapper;
import com.example.demo.entity.TableEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 * @ClassName TransactionServiceB
 * @Author bsy
 * @Description TODO
 * @Date 2022/8/25 21:58
 * @Version 1.0
 */
@Service
public class TransactionServiceB {

    @Autowired
    private TableMapper tableMapper;


    @Transactional
    //@Transactional(propagation  = Propagation.REQUIRES_NEW)
    //@Transactional(propagation  = Propagation.NESTED)
    public void methodB() throws Exception {
        tableMapper.insertTableB(new TableEntity());
        //模拟异常
        //throw new RuntimeException();
        throw new Exception();
    }
}
